package Controller.reply;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import Bean.ReplyBean;
import Dao.ReplyDao;

public class ReplyreplyController implements Controller{
	private ReplyDao dao;
	
	public void setDao(ReplyDao dao) {
		this.dao = dao;
	}
	@Override
	public ModelAndView handleRequest(HttpServletRequest req,
			HttpServletResponse arg1) throws Exception {
		System.out.println("리플에 리플달기 컨트롤러");
		Integer sr_no = Integer.parseInt(req.getParameter("sr_no"));
		System.out.println("댓글 시퀀스값"+sr_no);
		HttpSession session = req.getSession();
		String id = (String)session.getAttribute("member");
		ModelAndView mav = new ModelAndView();
		List<ReplyBean> rb = dao.replyreplyList(sr_no);
		
		for (ReplyBean reply : rb) {
			String m_id = reply.getSr_m_id();
			if(id.equals(m_id)){
				reply.setDisable("null");
			}else{
				reply.setDisable("disabled");
			}
		}
		
		mav.setViewName("replyreply");
		mav.addObject("sr_no", sr_no);
		mav.addObject("rb", rb);
		System.out.println("리플에 리플 출력 값이 있다.");
		return mav;
	}
}